use "build/output/main_panel.dta", clear
tsset coin_id date

********************************************************************************
* Regression: stablecoin interset rate from FTX on other observables
********************************************************************************

// binscatter margin_aprFTX e_rBTC_2m_annualized if coin == "USDT", nq(50)
// binscatter margin_aprFTX e_rBTC_2m_annualized if coin == "DAI", nq(50)

eststo clear
eststo: reg margin_aprFTX e_rBTC_2m_annualized, vce(cluster wdate)
estadd scalar adjR2 = round(`e(r2_a)',0.01), replace
estadd local month_fe "No"
estadd local coin_fe "No"

eststo: reg margin_aprFTX e_rBTC_2m_annualized r_btc i.mdate i.coin_id, vce(cluster wdate)
estadd scalar adjR2 = round(`e(r2_a)',0.01), replace
estadd local month_fe "Yes"
estadd local coin_fe "Yes"

eststo: reg margin_aprFTX e_rETH_2m_annualized, vce(cluster wdate)
estadd scalar adjR2 = round(`e(r2_a)',0.01), replace
estadd local month_fe "No"
estadd local coin_fe "No"

eststo: reg margin_aprFTX e_rETH_2m_annualized r_eth i.mdate i.coin_id, vce(cluster wdate)
estadd scalar adjR2 = round(`e(r2_a)',0.01), replace
estadd local month_fe "Yes"
estadd local coin_fe "Yes"

eststo: reg margin_aprFTX e_rBTC_2m_annualized e_rETH_2m_annualized, vce(cluster wdate)
estadd scalar adjR2 = round(`e(r2_a)',0.01), replace
estadd local month_fe "No"
estadd local coin_fe "No"

eststo: reg margin_aprFTX e_rBTC_2m_annualized e_rETH_2m_annualized e_rSP_2m_annualized r_btc r_eth i.mdate i.coin_id, vce(cluster wdate)
estadd scalar adjR2 = round(`e(r2_a)',0.01), replace
estadd local month_fe "Yes"
estadd local coin_fe "Yes"

esttab, drop(*.mdate *.coin_id _cons) star(* 0.10 ** 0.05 *** 0.01)
esttab using "analysis/output_tables/regression_stablecoin_r_on_er.tex", replace booktabs label drop(*.mdate _cons *coin_id) ///
	mgroups("Bitcoin" "Ether" "Both", pattern(1 0 1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
	prehead(\begin{tabular}{l S S S S S S} \toprule) ///
	posthead(\midrule) postfoot(\bottomrule\end{tabular}) ///
	style(tex) substitute(\_ _) star  b(2) t(2) r2(2) ///
	nomtitles /// 
	varlabels(e_rBTC_2m_annualized "\$\mathbb{E}[Ret^{\textit{BTC}}]\$" e_rETH_2m_annualized "\$\mathbb{E}[Ret^{\textit{ETH}}]\$" e_rSP_2m_annualized "\$\mathbb{E}[Ret^{\textit{S\&P}}]\$" r_btc "\$Ret^{\textit{BTC}}\$" r_eth "\$Ret^{\textit{ETH}}\$") ///
	interaction(" $\times$ ") /// 
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(N r2 month_fe coin_fe, fmt(%9.0fc 2) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") labels(`"\$N\$"' `"\(R^{2}\)"' `"Month FE"' `"Coin FE"'))
